<!DOCTYPE html>
<html lang="en">
<head>
    <title>添加</title>
    <%include("/WEB-INF/views/common/basejs.html"){}%>
    <script>
        layui.use(['form','layer','jquery'],function(){
            var form = layui.form
                ,layer = layui.layer,
                $=layui.jquery;
            //提交form监听表单
            form.on('submit(save)',function(data){
                //console.log(data.field) //当前容器的全部表单字段，名值对形式：{name: value}
                $.ajax({
                    url:basePath+'/role/save',
                    type:'post',
                    data:data.field,
                    dataType:'json',
                    success:function(data){
                        if(data.code==0){
                            //更新父元素的表格
                         window.parent.query();
                        }
                        window.parent.closeAddPage();
                        window.parent.layer.msg(data.msg);
                    },
                    error:function(){
                        layer.msg("系统内部错误");
                    }
                });
                return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
            });
        });
    </script>
</head>
<body>
<form class="layui-form layui-form-pane" action="" style="width:96%;margin:10px auto">
    <!--开始-->
    <!--角色名-->
    <div class="layui-form-item">
        <label class="layui-form-label">角色名</label>
        <div class="layui-input-block">
            <input name="roleName" type="text" lay-verify="required"   autocomplete="off" placeholder="请输角色名" class="layui-input">
        </div>
    </div>
    <!--部排序值-->
    <div class="layui-form-item">
        <label class="layui-form-label">排序值</label>
        <div class="layui-input-block">
            <input name="sort" type="number" autocomplete="off" placeholder="请输排序值" class="layui-input">
        </div>
    </div>
    <!--状态-->
    <div class="layui-form-item">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-block">
            <input type="radio" name="status" value="1" title="开启" checked>
            <input type="radio" name="status" value="2" title="禁用" >
        </div>
    </div>
    <!--角色描述-->
    <div class="layui-form-item">
        <label class="layui-form-label">角色描述</label>
        <div class="layui-input-block">
            <textarea name="roleDesc" placeholder="请输入角色描述" class="layui-textarea"></textarea>
        </div>
    </div>
    <!--结束-->
    <div class="layui-form-item layui-hide">
        <button id="form-submit" class="layui-btn" lay-submit lay-filter="save">保存</button>
    </div>
</form>
</body>
</html>